/********************************************
* Copyrigt (C) rumi
* Module: Serv_ComService.h
* V1.0.1
*********************************************/
#ifndef Serv_ComService_H
#define Serv_ComService_H

#include <iostream>
#include "Serv_CircularBuffer.h"
#include "Serv_Check.h"

typedef enum
{
	E_COMSERVICE_UART  = 0,
    E_COMSERVICE_CAN,
    E_COMSERVICE_FDCAN,
    E_COMSERVICE_USB,
    E_COMSERVICE_IIC,
    E_COMSERVICE_SPI,

}COM_SERVICE_DEVICE_ENUM;

typedef enum
{
	E_UART0  = 0,
    E_UART1,
    E_UART2,
    E_UART3,
    E_UART4,
    E_UART5,

}COM_SERVICE_UARTNUM_ENUM;


typedef enum
{
	E_COMFRAMEHEAD_NONE  = 0,
    E_COMFRAMEHEAD_NORMAL,
    E_COMFRAMEHEAD_UPDATE,

}COM_FRAME_HEAD_ENUM;

typedef enum
{
	E_COMFRAMETAIL_NONE  = 0,
    E_COMFRAMETAIL_JustFloat,
    E_COMFRAMETAIL_CRC8,
    E_COMFRAMETAIL_CRC16,
    E_COMFRAMETAIL_CRC36,

}COM_FRAME_CRC_ENUM;

typedef enum
{
	E_COMSENSENDSTATE_INIT  = 0,
    E_COMSENSENDSTAT_FRAMEHEAD,
    E_COMSENSENDSTAT_DATA,
    E_COMSENSENDSTAT_FRAMEEND,
    E_COMSENSENDSTAT_SEND,

}COM_SEND_STATE_ENUM;

// ComService_TxDevice
typedef struct {
    COM_SERVICE_DEVICE_ENUM Dev_Type;
    uint8_t ComDevice;
}ComService_TxDevice_Typedef;

// ComService_RxDevice
// typedef struct {   
//     CBuff RxCBuff;
//     COM_FRAME_HEAD_ENUM HeadFrame;
//     COM_FRAME_CRC_ENUM  CRCFrame;
//     void *(*ComSerivceFun)(uint8_t *);
// }ComService_RxDevice_Typedef;

// TansBuffer
typedef struct {
    COM_FRAME_HEAD_ENUM FrameHead;
    COM_FRAME_CRC_ENUM  FrameTail;
    uint16_t CAN_ID;
    uint16_t DataLen;
    uint8_t *Buffer;

}TansBuffer_Typedef;

extern ComService_TxDevice_Typedef Trace_TxUart;
bool ComService_Send(ComService_TxDevice_Typedef *ComDevice,TansBuffer_Typedef *Sendbuffer);
uint8_t *ComService_Rx_Handle(CBuff *Recive_CBuff);

#endif
/********************************************
 * End of file
*********************************************/
